package pl.edu.pw.polygen.menu.commands;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import pl.edu.pw.polygen.MainWindow;
import pl.edu.pw.polygen.PolygenApplication;
import pl.edu.pw.polygen.modeler.server.EditorServer;
import pl.edu.pw.polygen.ui.file.FileWindow;
import pl.edu.pw.polygen.util.ApplicationHelper;
import pl.edu.pw.polygen.util.ApplicationHolder;

import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.Panel;

@Component
public class NewFileCommand implements Command {

	@Autowired
	private FileWindow fileWindow;
	/**
	 * 
	 */
	private static final long serialVersionUID = -7161609692335521654L;
	private static final Logger LOG = Logger.getLogger(NewFileCommand.class);
	
	@Override
	public void menuSelected(MenuItem selectedItem) {
		System.out.println(selectedItem.getText());
		if (fileWindow.getParent() == null) {
			 fileWindow.init();
			 ApplicationHolder.getApplication().getMainWindow().addWindow(fileWindow);
		}
//		MainWindow mainWindow = (MainWindow) ((PolygenApplication)ApplicationHolder.getApplication()).getMainWindow();
//		mainWindow.addTab("Untitled",getPanel());
	}
}
